home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Hacks / Hacks ’90 / DataStack Filer / DataStacks.a < prev    next >
Encoding:
Text File  |  1990-06-14  |  760 b   |  26 lines  |  [TEXT/MPS ]

  1.                     CASE            ON
  2. FindKeyIndex    PROC            EXPORT         ;Modula saves registers across call.
  3.                                                     ;Modula clears the return value.
  4.  
  5.                     MOVEA.L        (SP)+,A0        ;get return address
  6.                     MOVE.W        (SP)+,D1        ;get totFil
  7.                     MOVE.W        (SP)+,D0        ;get index
  8.                     
  9.                     MOVE.L        (SP)+,D2        ;get array pointer
  10.                     ADDQ.L        #2,D2            ;point to first element [1]
  11.                     MOVEA.L        D2,A1            ;let's use it directly
  12.                     
  13. LOOP                CMP.W            (A1)+,D0        ;does it point to index?
  14.                     BEQ.S            ReturnVal
  15.                     DBF            D1,LOOP
  16.                     BRA.S            ExitGraceless
  17.                     
  18. ReturnVal        SUB.L            D2,A1            ;subtract out the pointer to [1]
  19.                     MOVE.L        A1,D2            ;(A1 points just past testee) 
  20.                     ASR.L            #1,D2            ;divide by 2
  21.                     MOVE.W        D2,(SP)        ;save in return space
  22.                     
  23. ExitGraceless    JMP            (A0)
  24.                     ENDP
  25.                     
  26.                     END